using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ApplicationBlocks.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace DataHelper.DAL
{
    public class Setting
    {
private static  string m_trConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

       #region SettingSelectAll
        public static SqlDataReader SettingSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
                return SqlHelper.ExecuteReader(ConnectionString, "SettingSelectAllRows",strSearch,top,bottom);
            return SqlHelper.ExecuteReader(m_trConnectionString, "SettingSelectAllRows",strSearch,top,bottom);
        }
        #endregion
       #region SettingSelectRow
        public static SqlDataReader SettingSelectRow(int ID, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
                return SqlHelper.ExecuteReader(ConnectionString, "SettingSelectRow", ID);
            return SqlHelper.ExecuteReader(m_trConnectionString, "SettingSelectRow", ID);
        }
        #endregion
       #region SettingInsertRow
        public static void SettingInsertRow(int ID, string Name, string Value, string Description, DateTime Updatedate, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
            {
                SqlHelper.ExecuteNonQuery(ConnectionString, "SettingInsertRow", ID, Name, Value, Description, Updatedate);
                return;
            }
            SqlHelper.ExecuteNonQuery(m_trConnectionString, "SettingInsertRow", ID, Name, Value, Description, Updatedate);
        }
        #endregion
       #region SettingUpdateRow
        public static void SettingUpdateRow(int ID, string Name, string Value, string Description, DateTime Updatedate, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
            {
                SqlHelper.ExecuteNonQuery(ConnectionString, "SettingUpdateRow", ID, Name, Value, Description, Updatedate);
                return;
            }
            SqlHelper.ExecuteNonQuery(m_trConnectionString, "SettingUpdateRow", ID, Name, Value, Description, Updatedate);
        }
        #endregion
       #region SettingDeleteRow
        public static void SettingDeleteRow(int ID, SqlTransaction ConnectionString = null)
        {
            if (ConnectionString != null)
            {
                SqlHelper.ExecuteNonQuery(ConnectionString, "SettingDeleteRow", ID);
                return;
            }
            SqlHelper.ExecuteNonQuery(m_trConnectionString, "SettingDeleteRow", ID);
        }
        #endregion

    }
}

